package com.xzh.wms.enums;


import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.Optional;


public enum ProductStatus {

    IN_STOCK(2,"下架"),
    OUT_STOCK(1,"上架"),
    DEFAULT(120,"删除");

    @Setter @Getter
    private int code;
    @Setter @Getter
    private String message;

    ProductStatus(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ProductStatus getByCode(int code){

        ProductStatus[] status=ProductStatus.values();
        Optional<ProductStatus> first = Arrays.stream(status).filter(items->items.code == code).findFirst();
        return first.orElse(null);

    }
}
